package 剑指offer;

public class 剑指offer05替换空格 {
    public static void main(String[] args) {
        String s = "he tom ,hello ";
        String s1 = replaceSpace(s);
        System.out.println(s1);
    }
    public static String replaceSpace(String s) {
        StringBuilder stringBuilder = new StringBuilder();
        int length = s.length();
        for (int i = 0; i < length; i++) {
            if (" ".equals(s.substring(i,i+1))){
                stringBuilder.append("%20");
                continue;
            }
            stringBuilder.append(s.substring(i,i+1));
        }
        return stringBuilder.toString();
    }
}
